﻿

/*-------------------------------------------------------------------------------------
 * Project Name             : Gems
 * Created By               : Naveen kumaar.P
 * Created Date             : 1 Nov 2012
 * Page Function            : 
 * -------------------------------------------------------------------------------------

*/


using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Data;

public partial class Gems : System.Web.UI.MasterPage
{
    Encrypt encryptobj = new Encrypt();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserType_ID"] != null)
        {
            lnkSignOut.Visible = true;
        }
        else
        {
            lnkSignin.Visible = true;
            signup.Visible = true;
        }
    }

    #region Button Event

    protected void btn_Login_Click(object sender, EventArgs e)
    {
        CheckUserDetails();
    }

    #endregion

    #region User Defined Function

    public void CheckUserDetails()
    {
        try
        {
            string encryptpwd = encryptobj.EncryptSring(txtpassword.Text);
            Hashtable hstbl1 = new Hashtable();
            hstbl1.Add("@UserName", txtusername.Text);
            hstbl1.Add("@Password", encryptpwd);
            DataTable dt = DataAccessLayer.GetDataTable("GemsUser_LoginCheck_SP", hstbl1);
            if (dt.Rows.Count > 0)
            {
                Session["UserType_ID"] = dt.Rows[0]["UserType_ID"].ToString();
                Session["UserName"] = dt.Rows[0]["UserName"].ToString();
                //Session.Timeout = 10;
                if (Session["UserType_ID"].ToString() == "1")
                {
                    Response.Redirect("~/OrderHistory.aspx", false);
                }
            }
            else
            {
                JSAlert.Show(Resources.Global.UserLoginValidation);
            }
        }
        catch (Exception ex)
        {
            JSAlert.Show(ex.Message);
        }

    }

    #endregion


    #region Link Event

   

    protected void lnkSignOut_Click(object sender, EventArgs e)
    {
        Session.Clear();
        Response.Redirect("index.aspx");


    }

    #endregion
}